﻿using System;
using System.Collections.Generic;
using System.Text;

namespace LandlordOff
{ 
    public abstract  class Status
    {
        public List<Record> History;
        public string CurrCards;
        public string LastCards;
        public int LandlordID;
        public string[] PlayerName;

        public Status()
        {
            History = new List<Record>();
        }            

        public override string ToString()
        {
            return string.Format ("当前出牌: {0}\t (地主:{1}, 底牌:{2})",CurrCards , PlayerName[LandlordID] ,LastCards );
        }
    }

    public class PlayerStatus : Status
    {
        public string OwnCards;

        public PlayerStatus(GameStatus gStatus, int playerID)
        {
            History = new List<Record>(gStatus.History);
            CurrCards = gStatus.CurrCards;
            LastCards = gStatus.LastCards;
            LandlordID = gStatus.LandlordID;
            PlayerName =(string[]) gStatus.PlayerName.Clone();
            OwnCards = gStatus.Cards[playerID];
        }

        public override string ToString()
        {
            return base.ToString()+"玩家拥有牌:"+OwnCards ;
        }
    }

    public class GameStatus : Status
    {
        public string[] Cards;

        public GameStatus()
            : base()
        { 
        }

        public void Update(int playerID, string cards)
        {

        }

        public override string ToString()
        {
            StringBuilder sb = new StringBuilder(); 
             for (int i = 0; i < Cards.Length;i++ )
                 sb.AppendLine(  base.PlayerName [i] +":"+Cards[0] );
             return base.ToString()+"\n"+sb.ToString()   ;
        }
    }

    public struct Record
    {
        public int ID;
        public string Cards;
        public bool IsBomb;

        public Record(int _id) : this(_id, "") { }

        public Record(int _id, string _cards) : this(_id, _cards, false) { }

        public Record(int _id, string _cards, bool _isBomb)
        {
            ID = _id; Cards = _cards;
            IsBomb = _isBomb;
        }

        public bool Pass
        {
            get { return string.IsNullOrEmpty(Cards); }
        }
    }

}
